package service

import (
	"context"
	"sftti-go-service/api"
	"sftti-go-service/dao"
	"sftti-go-service/types"

	"dubbo.apache.org/dubbo-go/v3/config"
	"github.com/dubbogo/gost/log/logger"
)

type PaperServiceImpl struct {
	api.UnimplementedPaperServiceServer
}

func (s *PaperServiceImpl) QuerySinglePaper(ctx context.Context, reqParams *api.ReqPaper) (*api.Paper, error) {
	logger.Infof("paper...")
	return &api.Paper{}, nil
}

func (s *PaperServiceImpl) QueryUserPapersPagely(ctx context.Context, reqPaper *api.ReqPaper) (res *api.PaperList, err error) {
	var dao dao.PaperDao = &dao.PaperDaoImpl{}

	daoMap := map[string]any{
		"userId": reqPaper.UserId,
	}

	var resPapers []types.Paper
	if reqPaper.HasDone {
		resPapers, err = dao.QueryUserDonePapers(daoMap)
	} else {
		resPapers, err = dao.QueryUserPapers(daoMap)
	}

	if err != nil {
		return res, err
	}

	
}

func init() {

	config.SetProviderService(&PaperServiceImpl{})

}
